#pragma once

#include<iostream>

using namespace std;

int BinarySearch(int arr[], int left, int right, int target)
{
	while (left <= right)
	{
		int mid = (left + right) / 2;
		if (arr[mid] == target)
		{
			return mid + 1;
		}
		else if (arr[mid] < target)
		{
			left = mid + 1;
		}
		else
		{
			right = mid - 1;
		}
	}
	return -1;
}